package Before826.AutoJudge;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class getAnswer {
    public List<String> GetTeacherAnswer(File file) {
        List<Student> students = new ArrayList<>();
        if (file.isDirectory() ) {
            File[] files = file.listFiles();
            if (files != null){
                for(File f : files){
                    List<String>  result= GetTeacherAnswer(f);
                    if (result != null){
                        return result;
                    }
                }
            }
        }
        if (file.getName().equals("标准答案.txt")) {
            try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
                List<String> list = new ArrayList<>();
                String line;
                while ((line = reader.readLine()) != null) {
                    list.add(line);
                }
                return list;
            } catch (IOException e) {
                System.out.println("读取文件时发生错误" + file.getName());
                e.printStackTrace();
            }

        }
        return null;
    }

}
